This invention pertains to archiving computer files and more particularly to archiving computer files that are open for writing.
In modern computer operations, many actions occur simultaneously. For example, a computer can be running several programs in memory at the same time, each using different data. This is especially true in a multi-user environment, where many users can be using the computer at the same time.
In such a multi-user environment, the computer is generally available for log-in at all times. The system cannot be closed to users while activities, such as back-up operations, are performed. The computer must be able to perform its administrative tasks without impacting users.
But when files are open for writing, the back-up operation can create a problem. With most types of files, the data in the file have an internal consistency that must be maintained. For example, if a file stores a letter, the contents convey a meaning. If the file is being written to change its meaning, the back-up operation should not begin until the write operation is complete. Otherwise, the archived file may include pieces from the different contents, and would lack consistency. On the other hand, the back-up operation cannot afford to wait until the file is completely written before archiving the file, as this could cause a potentially infinite delay in the archive operation (if users continue to open the same file before all other users have closed it).
Accordingly, a need remains for a method and apparatus that allows an archive operation to back up a consistent version of files even while the files are open for writing.
Whenever a file is opened for writing, a snapshot of the file is created. The snapshot includes a copy of the file""s metadata. A bitmap and snapshot file map are initialized. When new data are to be written to blocks in the file, the original contents of the blocks are duplicated. The bitmap is updated to identify the changed blocks. The snapshot file map is updated to point to the duplicate blocks. The new data are then written to the original blocks. When the file is to be archived, the file system uses the bitmap to determine whether to access the blocks from the original or snapshot file map. Finally, when the file is closed and the archive operation is complete, the resources used by the snapshot are returned to the system.
The foregoing and other features, objects, and advantages of the invention will become more readily apparent from the following detailed description, which proceeds with reference to the accompanying drawings.